<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <ui:composition template="/shared/_layout.xhtml">
        <ui:define name="title">
            Espace d'administration de BooXtore.com
        </ui:define>
        <ui:define name="css">
            <h:outputStylesheet library="css" name="form.css"/>
            <h:outputStylesheet library="css/library" name="index.css"/>
        </ui:define>
        <ui:define name="content">
            <f:event listener="#{accountLogin.isNotLogged()}" type="preRenderView" />
            <h1>Gestion des livres.</h1>
            <h2>Modification du nombre de livre par page</h2>
            <h:form>
                <p>
                    <h:messages errorClass="errorMessage" infoClass="infoMessage" warnClass="warnMessage"/>
                </p>
                <p>
                    <h:inputText label="Paramètre" required="true" value="#{libraryManager.paramaters.articlePage}"/>
                    <h:commandButton value="Modifier" action="#{libraryManager.updateParameter()}"/>
                </p>
            </h:form>

            <h2>Modification, suppression d'un livre existant</h2>
            <section>
                <h:dataTable class="books" value="#{libraryManager.articles}" var="entry" columnClasses="books-id, ,books-option">
                    <h:column>
                        <f:facet name="header"></f:facet>
                        <h:outputText value="#{entry.IDarticles}"/>
                    </h:column>
                    <h:column>
                        <f:facet name="header">Nom</f:facet>
                        <h:outputText value="#{entry.name}"/>
                    </h:column>
                    <h:column>
                        <f:facet name="header"></f:facet>
                        <h:form>
                            <h:commandButton value="Modifier" action="#{libraryManager.selectArticle(entry)}"/>
                            <h:outputText value=" "/>
                            <h:commandButton value="Supprimer" action="#{libraryManager.delete(entry)}"/>
                        </h:form>
                    </h:column>
                </h:dataTable>
                <p>
                    <h:link outcome="/index" class="back" value="Retour"/>
                </p>
            </section>
        </ui:define>
    </ui:composition>
</html>